package com.bawan.vims.service;

import java.io.Serializable;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.bawan.vims.dao.IBaseDao;

/**
 * <p> Description	: BaseServiceImpl.java </p>
 * <p> Copyright	: Copyright (c) 2015 by FITT</p>
 * <p> Author 		: ZCC </p>
 * <p> Create		: 2015年1月30日 上午9:39:03 </p> 
 * <p> version 		: 1.0 </p>
 */
@Transactional
public abstract class BaseService<T extends Serializable> implements IBaseDao<T> {
	
	@Autowired
	protected IBaseDao<T> baseDao;

	public List<T> findAll() {
		return baseDao.findAll();
	}

	public T findById(Serializable id) {
		return baseDao.findById(id);
	}

	public boolean save(T entity) {
		return baseDao.save(entity);
	}

	public boolean update(T entity) {
		return baseDao.update(entity);
	}

	public boolean delete(T entity) {
		return baseDao.delete(entity);
	}
	
	protected String getClassNameAndMethod(){
		StackTraceElement[] stacks = new Throwable().getStackTrace();    
        StringBuilder sb=new StringBuilder();
        sb.append("[" ).append(this.getClass().getSimpleName()).append(".").append(stacks[1].getMethodName()).append("]  ");
        return sb.toString();
	}
}
